package cn.tedu.egmvc2.controller;

import cn.tedu.egmvc2.mapper.AddressMapper;
import cn.tedu.egmvc2.pojo.entity.Address;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address/")
public class AddressController {

    @Autowired
    private AddressMapper addressMapper;

    @RequestMapping("insert")
    public String insert(Address address){
        int i = addressMapper.insert(address);
        if (i>1){
        return "添加成功";
        }
        return "添加失败";
    }

    @RequestMapping("select")
    public List<Address> selectList(){
        return addressMapper.selectList();
    }

    @RequestMapping("delete")
    public String delete(Integer id){
        int i = addressMapper.delete(id);
        if (i>0) {
            return "删除成功";
        }
        return "删除失败";
    }

    @RequestMapping("update")
    public String update(Address address){
        int i = addressMapper.update(address) ;
        if (i>0){
            return "修改成功";
        }
        return "修改失败";
    }



}
